home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / basic / landscaper / landscaper.bb2 < prev    next >
Text File  |  1999-01-25  |  41KB  |  1,496 lines

  1. ; *****************************************
  2. ; *                                       *
  3. ; *     Landscaping by David McMinn       *
  4. ; *  (not a gardening program, idiot)     *
  5. ; *                                       *
  6. ; *  Run this or be slapped in the face   *
  7. ; *  (only kidding but run it cos you`ll  *
  8. ; *            like it)                   *
  9. ; *                                       *
  10. ; *****************************************
  11. ; *                                       *
  12. ; * Program name: Landmakerv2_2.bb2       *
  13. ; * Created     : 21/9/95                 *
  14. ; * Last Saved  : 5/12/95                 *
  15. ; *                                       *
  16. ; *****************************************
  17.  
  18. ; *** Useful functions (not for map drawing) ***
  19.  
  20. Statement centre{a$,ww}
  21.   x=(ww-12-Len(a$)*8)/2
  22.   WLocate x,WCursY
  23.   NPrint a$
  24. End Statement
  25.  
  26. Statement wprint{a$}
  27.   WLocate 5,2
  28.   InnerCls
  29.   For i=1 To 3
  30.     Redraw 0,i
  31.   Next
  32.   Print a$
  33. End Statement
  34.  
  35.  
  36. ; *** Set up startup stuff ***
  37.  
  38. WBStartup:NoCli
  39. CloseEd
  40.  
  41. If ExecVersion<37 Then End
  42.  
  43. WbToScreen 0
  44. WBenchToFront_
  45.  
  46. *scr._Screen = Peek.l(Addr Screen(0))
  47.  
  48. AddIDCMP $10
  49. RRandomize Timer
  50.  
  51. SetErr
  52.   End
  53. End SetErr
  54.  
  55. ;*** Set all startup variables ***
  56.  
  57.   wbw.l=*scr\Width
  58.   wbh.l=*scr\Height
  59.  
  60.   dsize.w=10
  61.   dxscale.q=8
  62.   dyscale.q=4
  63.   dzscale.q=1
  64.   dfaults.l=100
  65.   ddelta.q=3
  66.  
  67.   size.w=10
  68.   xscale.q=8
  69.   yscale.q=4
  70.   zscale.q=1
  71.   circular=1
  72.   linear=0
  73.   faults.l=100
  74.   delta.q=3
  75.   scrmd.w=1
  76.   clrs.w=1
  77.  
  78.   osize.w=size
  79.   oxscale.q=xscale
  80.   oyscale.q=yscale
  81.   ozscale.q=zscale
  82.   ocircular=circular
  83.   olinear=linear
  84.   ofaults.l=faults
  85.   odelta.q=delta
  86.   oscrmd.w=scrmd
  87.   oclrs.w=clrs
  88.  
  89.   map=0
  90.   iff=0
  91.   aga=CheckAGA
  92.  
  93.   *smr.ScreenModeRequester = 0
  94.   idhandle.l = 0
  95.   DEFTYPE.ScreenModeRequester mode, newmode
  96.   DEFTYPE.NameInfo ni
  97.   mode\sm_DisplayID = 0,320,200,4
  98.   idhandle=FindDisplayInfo_(mode\sm_DisplayID)
  99.   GetDisplayInfoData_ idhandle,&ni,SizeOf.NameInfo,$80003000,0
  100.  
  101.   MaxLen pa$=192
  102.   MaxLen fi$=192
  103.  
  104.   NEWTYPE.tri
  105.     x1.w
  106.     y1.w
  107.     x2.w
  108.     y2.w
  109.     x3.w
  110.     y3.w
  111.   End NEWTYPE
  112.  
  113.   DEFTYPE.tri stuff
  114.  
  115.   NEWTYPE.pal
  116.     r.w
  117.     g.w
  118.     b.w
  119.   End NEWTYPE
  120.  
  121.   DEFTYPE.w rr,gg,bb
  122.   Dim dcolours.ColorSpec(33),colours.ColorSpec(33)
  123.   Restore colourvalues
  124.   For i=0 To 31
  125.     Read rr,gg,bb
  126.     dcolours(i)\ColorIndex=i,rr,gg,bb
  127.     colours(i)\ColorIndex=i,rr,gg,bb
  128.   Next
  129.   dcolours(32)\ColorIndex=-1
  130.   colours(32)\ColorIndex=-1
  131.  
  132.   Dim s.b(2),x.b(2),y.b(2),height.q(4)
  133.  
  134. ; *** Set up menus ***
  135.  
  136. MenuTitle 0,0,"Project"
  137. MenuItem 0,0,0,0,"Load map      ","L"
  138. MenuItem 0,0,0,1,"Save       "+Chr$(187)
  139. SubItem 0,0,0,1,0,"Save IFF      ","S"
  140. SubItem 0,0,0,1,1,"Save map      ","M"
  141. MenuItem 0,0,0,2,"About         ","A"
  142. MenuItem 0,0,0,3,"Quit          ","Q"
  143. MenuTitle 0,1,"Landscape"
  144. MenuItem 0,0,1,0,"Options       ","?"
  145. MenuItem 0,0,1,1,"Generate      ","G"
  146. MenuItem 0,0,1,2,"Show map      "
  147.  
  148.  
  149. ; *** Set up GUI gadgets for main window ***
  150.  
  151. GTButton 0,1,18,23,84,12,"Generate",$10
  152. GTButton 0,2,123,23,52,12,"Stop",$10|$40|$80
  153. GTButton 0,3,200,23,76,12,"Options",$10
  154.  
  155.  
  156. ; *** Set up GUI gadgets for options window ***
  157.  
  158. GTInteger 1,1,100,5,64,14,"Faults",$1,0
  159. GTInteger 1,2,100,19,64,14,"Size",$1,0
  160. GTInteger 1,3,100,33,64,14,"X scale",$1,0
  161. GTInteger 1,4,100,47,64,14,"Y scale",$1,0
  162. GTInteger 1,5,100,61,64,14,"Z scale",$1,0
  163. GTInteger 1,6,100,75,64,14,"Delta",$1,0
  164. GTCheckBox 1,7,100,89,12,14,"Circular",$1
  165. GTCheckBox 1,8,100,103,12,14,"Linear",$1
  166. GTText  1,9,100,117,198,14,"Screen Mode",#PLACETEXT_LEFT,""
  167. GTNumber 1,10,100,131,32,14,"Depth",#PLACETEXT_LEFT,mode\sm_DisplayDepth
  168. GTButton 1,11,26,150,82,14,"Default",$30
  169. GTButton 1,12,134,150,82,14,"Help me",$30
  170. GTButton 1,13,74,173,68,14,"OK",$10
  171. GTButton 1,14,212,173,68,14,"CANCEL",$10
  172. GTButton 1,15,242,150,82,14,"Palette",$30
  173. GTButton 1,16,300,117,30,14,"(?)",#PLACETEXT_IN
  174.  
  175. ; *** Show user interface and other muck ***
  176.  
  177. ww.w = *scr\WBorLeft+300+*scr\WBorRight
  178. wh.w = *scr\WBorTop+*scr\Font\ta_YSize+1+50+*scr\WBorBottom
  179. Window 0,(wbw-ww)/2,(wbh-wh)/2,ww,wh,$2|$4|$8|$1000,"Landscaper V1.12 by Dave McMinn",-1,-1
  180.  
  181. SetMenu 0
  182.  
  183. AttachGTList 0,0
  184.  
  185. exit=0
  186. While exit=0
  187.   .mainloop:
  188.   ev.l=WaitEvent
  189.   Select ev
  190.     Case $200:exit=1;                   Has close gadget been pressed
  191.     Case $100;                          Has a menu e_vent occurred
  192.       Select MenuHit
  193.         Case 0;                         Something from project menu
  194.           Select ItemHit
  195.             Case 0:Gosub loadmap;       Load map
  196.             Case 1
  197.               Select SubHit
  198.                 Case 0:Gosub saveiff;   Save IFF
  199.                 Case 1:Gosub savemap;   Save map
  200.               End Select
  201.             Case 2:Gosub info;          M-Hinfo
  202.             Case 3:exit=1;              Quit
  203.           End Select
  204.         Case 1;                         Something from Landscape menu
  205.           Select ItemHit
  206.             Case 0:Gosub options;       Options is chosen
  207.             Case 1:Gosub gennew;        Generate new map
  208.             Case 2:Gosub showold;       Show old map
  209.           End Select
  210.       End Select
  211.     Case $40;                           a gadget E_vent
  212.       Select GadgetHit
  213.         Case 1          ;               Generate has been picked
  214.             If mode\sm_DisplayID=0
  215.                 body$="If you want to see the picture you need"+Chr$(10)
  216.                 body$+"to pick a screenmode from the options."+Chr$(10)
  217.                 body$+"What do you want to do?"
  218.                 dummy=EasyRequest("Information",body$,"Options|Continue")
  219.                 If dummy=1 Then Gosub options
  220.             End If
  221.             Gosub gennew
  222.         Case 3:Gosub options;           Options has been picked
  223.       End Select
  224.   End Select
  225. Wend
  226. End
  227.  
  228. .loadmap:
  229.   f$=ASLFileRequest$("Load a map file",pa$,fi$)
  230.   If f$
  231.     wprint{"Loading map file..."}
  232.     If ReadFile(0,f$)
  233.       FileInput 0
  234.       filetype$=Inkey$(6)
  235.       If filetype$="McMinn"
  236.         osize=Cvi(Inkey$(2))
  237.         size=osize
  238.         xscale=Cvq(Inkey$(4))
  239.         yscale=Cvq(Inkey$(4))
  240.         zscale=Cvq(Inkey$(4))
  241.         faults=Cvl(Inkey$(4))
  242.         delta=Cvq(Inkey$(4))
  243.         Dim land.q(size+1,size+1)
  244.         For i=0 To size
  245.           For j=0 To size
  246.             land(i,j)=Cvq(Inkey$(4))
  247.           Next
  248.         Next
  249.         map=1
  250.         wprint{""}
  251.       Else
  252.         wprint{"Not a Landscaper file."}
  253.       End If
  254.       CloseFile 0
  255.       DefaultInput
  256.     Else
  257.       wprint{"Could not load data file."}
  258.     End If
  259.   End If
  260.   Return
  261.  
  262. .saveiff:
  263.   If iff=1
  264.     f$=ASLFileRequest$("Save IFF image",pa$,fi$)
  265.     If f$
  266.       ovr=1
  267.       If Exists(f$)
  268.         ovr=EasyRequest("Landscape Request","Do you wish to overwrite|"+Chr$(10)+f$," Yes | No ")
  269.       End If
  270.       If ovr=1
  271.         wprint{"Saving IFF image ..."}
  272.         SaveBitmap 0,f$,0
  273.         wprint{""}
  274.       End If
  275.     End If
  276.   Else
  277.     wprint{"No IFF in memory."}
  278.   End If
  279.   Return
  280.  
  281. .savemap:
  282.   If map=1
  283.     f$=ASLFileRequest$("Save a map file",pa$,fi$)
  284.     If f$
  285.       ovr=1
  286.       If Exists(f$)
  287.         ovr=EasyRequest("Landscape Request","Do you wish to overwrite"+Chr$(10)+f$," Yes | No ")
  288.       End If
  289.       If ovr=1
  290.         wprint{"Saving map file ..."}
  291.         If WriteFile(0,f$)
  292.           FileOutput 0
  293.           Print "McMinn"
  294.           Print Mki$(osize)
  295.           Print Mkq$(oxscale)
  296.           Print Mkq$(oyscale)
  297.           Print Mkq$(ozscale)
  298.           Print Mkl$(ofaults)
  299.           Print Mkq$(odelta)
  300.           For i=0 To osize
  301.             For j=0 To osize
  302.               Print Mkq$(land(i,j))
  303.             Next
  304.           Next
  305.           CloseFile 0
  306.           DefaultOutput
  307.         Else
  308.           wprint{"Could not save data file."}
  309.         End If
  310.       End If
  311.     End If
  312.     wprint{""}
  313.   Else
  314.     wprint{"No map in memory."}
  315.   End If
  316.   Return
  317.  
  318. .info:
  319.   Restore infotext
  320.   about$=""
  321.   For i=0 To 13
  322.     Read text$
  323.     about$=about$+text$+Chr$(10)
  324.   Next
  325. ;  about$=about$+Chr$(10)
  326. ;  about$=about$+Str$(?????)+" bytes Chip free"+Chr$(10)
  327. ;  about$=about$+Str$(?????)+" bytes Fast free"+Chr$(10)
  328.   EasyRequest "About Landscaper",about$,"OK"
  329.   Return
  330.  
  331. .gennew:
  332.   GTDisable 0,1
  333.   GTEnable 0,2
  334.   GTDisable 0,3
  335.   For i=1 To 3
  336.     Redraw 0,i
  337.   Next
  338.   Dim land.q(size+1,size+1)
  339.   Gosub init
  340.   Gosub shift
  341.   Gosub levels
  342.   Gosub draw
  343.   Return
  344.  
  345. .showold:
  346.   If map=1
  347.     GTDisable 0,1
  348.     GTEnable 0,2
  349.     GTDisable 0,3
  350.     For i=1 To 3
  351.       Redraw 0,i
  352.     Next
  353.     size=osize
  354.     Gosub init
  355.     Gosub levels
  356.     Gosub draw
  357.   Else
  358.     WLocate 5,2
  359.     InnerCls
  360.     For i=1 To 3
  361.       Redraw 0,i
  362.     Next
  363.     Print "No map in memory."
  364.   End If
  365.   Return
  366.  
  367. .options:
  368.   Menus Off
  369.  
  370.   oww.w = *scr\WBorLeft+350+*scr\WBorRight
  371.   owh.w = *scr\WBorTop+*scr\Font\ta_YSize+1+200+*scr\WBorBottom
  372.   Window 1,(wbw-oww)/2,(wbh-owh)/2,oww,owh,$1000,"             Rendering Options",-1,-1
  373.  
  374.   smok.w = 0
  375.  
  376.   AttachGTList 1,1
  377.   idhandle=FindDisplayInfo_(mode\sm_DisplayID)
  378.   If GetDisplayInfoData_(idhandle,&ni,SizeOf.NameInfo,$80003000,0)
  379.     GTSetString 1,9,Peek$(&ni\Name)
  380.   Else
  381.     GTSetString 1,9,""
  382.   End If
  383.   GTSetInteger 1,1,faults
  384.   GTSetInteger 1,2,size
  385.   GTSetInteger 1,3,xscale
  386.   GTSetInteger 1,4,yscale
  387.   GTSetInteger 1,5,zscale
  388.   GTSetInteger 1,6,delta
  389.   If circular=1
  390.     GTToggle 1,7,On
  391.   Else
  392.     GTToggle 1,7,Off
  393.   End If
  394.   If linear=1
  395.     GTToggle 1,8,On
  396.   Else
  397.     GTToggle 1,8,Off
  398.   End If
  399.  
  400.   GTDisable 0,1:Redraw 0,1
  401.   GTDisable 0,3:Redraw 0,3
  402.  
  403.   Redraw 1,7
  404.   Redraw 1,8
  405.  
  406.   newmode\sm_DisplayID = mode\sm_DisplayID,mode\sm_DisplayWidth,mode\sm_DisplayHeight,mode\sm_DisplayDepth
  407.  
  408.  
  409.   While exit=0
  410.     ev=WaitEvent
  411.     Select ev
  412.       Case #IDCMP_CLOSEWINDOW
  413.         exit=1
  414.       Case #IDCMP_GADGETUP;            Gadget is released
  415.         Select GadgetHit
  416. ;          Case 9:tmp1=EventCode;        Screenmode cycle
  417. ;          Case 10:tmp2=EventCode;       Colours cycle
  418.           Case 11;                      Defaults button
  419.             GTSetInteger 1,1,dfaults
  420.             GTSetInteger 1,2,dsize
  421.             GTSetInteger 1,3,dxscale
  422.             GTSetInteger 1,4,dyscale
  423.             GTSetInteger 1,5,dzscale
  424.             GTSetInteger 1,6,ddelta
  425.             GTToggle 1,7,On
  426.             Redraw 1,7
  427.             GTToggle 1,8,Off
  428.             Redraw 1,8
  429.           Case 12:Gosub helpme;         Help me! button
  430.           Case 13;                      OK button
  431.             faults=GTGetInteger(1,1)
  432.             size=GTGetInteger(1,2)
  433.             If size<2 Then size=2
  434.             If size>160 Then size=160
  435.             xscale=GTGetInteger(1,3)
  436.             yscale=GTGetInteger(1,4)
  437.             If yscale<0 Then yscale=0
  438.             zscale=GTGetInteger(1,5)
  439.             If zscale<0 Then zscale=0
  440.             delta=GTGetInteger(1,6)
  441.             circular=Abs(GTStatus(1,7))
  442.             linear=Abs(GTStatus(1,8))
  443.             mode\sm_DisplayID = newmode\sm_DisplayID,newmode\sm_DisplayWidth,newmode\sm_DisplayHeight,newmode\sm_DisplayDepth
  444.             idhandle=FindDisplayInfo_(mode\sm_DisplayID)
  445.             GetDisplayInfoData_ idhandle,&ni,SizeOf.NameInfo,$80003000,0
  446.             exit=1
  447.           Case 14:exit=1;               CANCEL button
  448.           Case 15
  449.             If newmode\sm_DisplayID=0
  450.                 opttemp$="In the interest of your sanity,"+Chr$(10)
  451.                 opttemp$+"please select a screenmode first,"+Chr$(10)
  452.                 opttemp$+"with the (?) gadget"
  453.                 dummy=EasyRequest("Warning!",opttemp$,"I will")
  454.             Else
  455.                 Gosub alette;         Palette button
  456.             End If
  457.           Case 16:Gosub srequest
  458.  
  459.         End Select
  460.     End Select
  461.   Wend
  462.   exit=0
  463.   DetachGTList 1
  464.   Free Window 1
  465.   Use Window 0
  466.   GTEnable 0,1:Redraw 0,1
  467.   GTEnable 0,3:Redraw 0,3
  468.   Menus On
  469.   Return
  470.  
  471. srequest:
  472.     Dim SMRtags.TagItem(18)
  473.     SMRtags(0)\ti_Tag=#ASLSM_InitialLeftEdge,160     ;these are the position for the
  474.     SMRtags(1)\ti_Tag=#ASLSM_InitialTopEdge,10       ;screenmode requester
  475.     SMRtags(2)\ti_Tag=#ASLSM_InitialWidth,320
  476.     SMRtags(3)\ti_Tag=#ASLSM_InitialHeight,200
  477.     SMRtags(4)\ti_Tag=#ASLSM_InitialDisplayID,newmode\sm_DisplayID
  478.     SMRtags(5)\ti_Tag=#ASLSM_InitialDisplayDepth,newmode\sm_DisplayDepth
  479.     SMRtags(6)\ti_Tag=#ASLSM_InitialDisplayWidth,newmode\sm_DisplayWidth
  480.     SMRtags(7)\ti_Tag=#ASLSM_InitialDisplayHeight,newmode\sm_DisplayHeight
  481.     SMRtags(8)\ti_Tag=#ASLSM_InitialInfoOpened,0
  482.     SMRtags(9)\ti_Tag=#ASLSM_DoDepth,1              ;0 for no depth selector
  483.     SMRtags(10)\ti_Tag=#ASLSM_DoOverscanType,0       ;0 for no OverScan selector
  484.     SMRtags(11)\ti_Tag=#ASLSM_DoWidth,1              ;0 for no width gadget
  485.     SMRtags(12)\ti_Tag=#ASLSM_DoHeight,1             ;0 for no height gadget
  486.     SMRtags(13)\ti_Tag=#ASLSM_MinHeight,200          ;minimum height allowed
  487.     SMRtags(14)\ti_Tag=#ASLSM_MinWidth,320           ;minimum width allowed
  488.     SMRtags(15)\ti_Tag=#ASLSM_MinDepth,4             ;minimum depth allowed
  489.     SMRtags(16)\ti_Tag=#ASLSM_MaxDepth,5
  490.     SMRtags(17)\ti_Tag=#TAG_END
  491.  
  492.     *smr=AllocAslRequest_(2,&SMRtags(0)\ti_Tag)
  493.     smok=AslRequest_(*smr,&SMRtags(0)\ti_Tag)
  494.  
  495.     If smok<>0
  496.         newmode\sm_DisplayID = *smr\sm_DisplayID,*smr\sm_DisplayWidth,*smr\sm_DisplayHeight,*smr\sm_DisplayDepth
  497.         idhandle=FindDisplayInfo_(newmode\sm_DisplayID)
  498.         GetDisplayInfoData_ idhandle,&ni,SizeOf.NameInfo,$80003000,0
  499.         GTSetString 1,9,Peek$(&ni\Name)
  500.         GTSetInteger 1,10,newmode\sm_DisplayDepth
  501.     EndIf
  502.     If *smr Then FreeAslRequest_ *smr
  503.     Return
  504.  
  505. .helpme:
  506.   Restore helptext
  507.   about$=""
  508.   For i=1 To 13
  509.     Read text$
  510.     about$=about$+text$+Chr$(10)
  511.   Next
  512.   EasyRequest "Landscaper Help",about$,"OK"
  513.   Return
  514.  
  515. .alette:
  516.     ; *** Set up GUI for palette changing window ***
  517.     #tag=$80080000
  518.  
  519.     #gtsl_level=#tag+40
  520.     #gtsl_maxlevellen=#tag+41
  521.     #gtsl_levelformat=#tag+42
  522.     #gtsl_levelplace=#tag+43
  523.  
  524.     lfor$="%2ld"
  525.  
  526.     current=1
  527.     GTPalette 2,1,16,85,600,50,"",$8,newmode\sm_DisplayDepth
  528.  
  529.     GTTags #gtsl_levelformat,&lfor$,#gtsl_maxlevellen,4,#gtsl_levelplace,$2
  530.     GTSlider 2,2,155,10,150,12,"Red",$81,0,15
  531.  
  532.     GTTags #gtsl_levelformat,&lfor$,#gtsl_maxlevellen,4,#gtsl_levelplace,$2
  533.     GTSlider 2,3,155,24,150,12,"Green",$81,0,15
  534.  
  535.     GTTags #gtsl_levelformat,&lfor$,#gtsl_maxlevellen,4,#gtsl_levelplace,$2
  536.     GTSlider 2,4,155,38,150,12,"Blue",$81,0,15
  537.  
  538.     GTButton 2,5,16,167,60,12,"Load",$10
  539.     GTButton 2,6,80,167,60,12,"Save",$10
  540.  
  541.     GTButton 2,7,180,167,80,12,"Default",$10
  542.     GTButton 2,8,264,167,80,12,"Spread",$10
  543.     GTButton 2,9,348,167,80,12,"Copy",$10
  544.     GTButton 2,10,432,167,80,12,"Exch.",$10
  545.  
  546.     GTButton 2,11,160,220,80,12,"OK",$10
  547.     GTButton 2,12,400,220,80,12,"CANCEL",$10
  548.  
  549.     GTText 2,13,50,197,540,12,"Messages",$4," "
  550.  
  551.  
  552.     ;Screen 1,13
  553.     Dim SCRtags.TagItem(10)
  554.  
  555.     SCRtags(0)\ti_Tag=#SA_DisplayID,newmode\sm_DisplayID
  556.     SCRtags(1)\ti_Tag=#SA_Depth,newmode\sm_DisplayDepth
  557.     SCRtags(2)\ti_Tag=#SA_Width,640
  558.     SCRtags(3)\ti_Tag=#SA_Height,400
  559.     SCRtags(4)\ti_Tag=#SA_AutoScroll,-1
  560.     SCRtags(5)\ti_Tag=#SA_Overscan,#OSCAN_TEXT
  561.     SCRtags(6)\ti_Tag=#SA_Top,0
  562.     SCRtags(7)\ti_Tag=#SA_Left,0
  563.     SCRtags(8)\ti_Tag=#SA_ShowTitle,0
  564.     SCRtags(9)\ti_Tag=#TAG_END
  565.  
  566.     If newmode\sm_DisplayWidth > 640
  567.         SCRtags(2)\ti_Tag=#SA_Width,newmode\sm_DisplayWidth
  568.     End If
  569.  
  570.     If newmode\sm_DisplayHeight > 400
  571.         SCRtags(3)\ti_Tag=#SA_Height,newmode\sm_DisplayHeight
  572.     End If
  573.  
  574.     If ScreenTags(1,"",&SCRtags(0))
  575.         Use Palette 0
  576.         blank$="                              "
  577.         current=1
  578.  
  579.         Window 2,0,0,640,256,$1000,"Palette ...",-1,-1
  580.  
  581.         For i=0 To (1 LSL newmode\sm_DisplayDepth - 1)
  582.             RGB i,colours(i)\_Red,colours(i)\_Green,colours(i)\_Blue
  583.         Next
  584.  
  585.         AttachGTList 2,2
  586.  
  587.         GTBevelBox 2,355,21,80,40,40
  588.         WBox 362,24,427,57,current
  589.         GTSetAttrs 2,2,#gtsl_level,Red(current)
  590.         GTSetAttrs 2,3,#gtsl_level,Green(current)
  591.         GTSetAttrs 2,4,#gtsl_level,Blue(current)
  592.  
  593.         WLocate 16,75
  594.         Print "Back  Sea Sand Lowest",SPACE$(16),"Land Shading",SPACE$(18),"Highest"
  595.         If newmode\sm_DisplayDepth=5
  596.             WLocate 24,145
  597.             Print "Deepest       Water shades (32 colour only)         Shallowest   Not Used"
  598.         End If
  599.  
  600.  
  601.         exit=0
  602.         While exit=0
  603.             If ev.l<>$10;;              If previous Event was NOT a Mouse MOVE
  604.                 ev2.l=ev.l;               set previous event
  605.             End If
  606.             ev.l=WaitEvent
  607.             Select ev
  608.                 Case $10
  609.                     If ev2=$20;;            If previous Event was a button held down
  610.                         Select GadgetHit;     i.e. slider was dragged
  611.                             Case 2;             If its red thats changed
  612.                                 RGB current,EventCode,Green(current),Blue(current)
  613.  
  614.                             Case 3;             If its green thats changed
  615.                                 RGB current,Red(current),EventCode,Blue(current)
  616.  
  617.                             Case 4;             If its blue thats changed
  618.                                 RGB current,Red(current),Green(current),EventCode
  619.                         End Select
  620.                     End If
  621.                 Case #IDCMP_GADGETUP
  622.                     Select GadgetHit
  623.                         Case 1;               Palette is pressed
  624.                             current=EventCode
  625.                             WBox 362,24,427,57,current
  626.                             GTSetAttrs 2,2,#gtsl_level,Red(current)
  627.                             GTSetAttrs 2,3,#gtsl_level,Green(current)
  628.                             GTSetAttrs 2,4,#gtsl_level,Blue(current)
  629.  
  630.                         Case 2;               Has red been changed
  631.                             RGB current,EventCode,Green(current),Blue(current)
  632.  
  633.                         Case 3;               Has green been changed
  634.                             RGB current,Red(current),EventCode,Blue(current)
  635.  
  636.                         Case 4;               Has blue been changed
  637.                             RGB current,Red(current),Green(current),EventCode
  638.  
  639.                         Case 5;               Loooooooooaaaaaaaad
  640.                             f$=ASLFileRequest$("Load a palette",pa$,fi$)
  641.                             If ReadFile(0,f$)
  642.                                 FileInput 0
  643.                                 If Lof(0)>12
  644.                                     FileSeek 0,8
  645.                                     filetype$=Inkey$(4)
  646.                                     If filetype$="ILBM"
  647.                                         GTSetString 2,13,"Loading palette..."+SPACE$(10)
  648.                                         LoadPalette 0,f$
  649.                                         Use Palette 0
  650.                                         GTSetString 2,13,blank$
  651.                                     Else
  652.                                         GTSetString 2,13,"Not a CMAP palette file.    "
  653.                                     End If
  654.                                 End If
  655.                                 DefaultInput
  656.                             End If
  657.  
  658.                         Case 6;               Saaaaaaaaave
  659.                             f$=ASLFileRequest$("Save palette as",pa$,fi$)
  660.                             If f$
  661.                                 ovr=1
  662.                                 If Exists(f$)
  663.                                     ovr=EasyRequest("Landscape Request","Do you wish to overwrite"+Chr$(10)+f$," Yes | No ")
  664.                                 End If
  665.                                 If ovr=1
  666.                                     GTSetString 2,13,"Saving palette..."+SPACE$(10)
  667.                                     SavePalette 0,f$
  668.                                     GTSetString 2,13,blank$
  669.                                 End If
  670.                             End If
  671.                         Case 7;               Default
  672.                             For i=0 To (1 LSL newmode\sm_DisplayDepth - 1)
  673.                                 rr=dcolours(i)\_Red
  674.                                 gg=dcolours(i)\_Green
  675.                                 bb=dcolours(i)\_Blue
  676.                                 RGB i,rr,gg,bb
  677.                             Next
  678.                             GTSetAttrs 2,2,#gtsl_level,dcolours(current)\_Red
  679.                             GTSetAttrs 2,3,#gtsl_level,dcolours(current)\_Green
  680.                             GTSetAttrs 2,4,#gtsl_level,dcolours(current)\_Blue
  681.  
  682.                         Case 8;               Spread
  683.                             For i=2 To 12
  684.                                 GTDisable 2,i
  685.                                 Redraw 2,i
  686.                             Next
  687.                             GTSetString 2,13,"Select colour to spread to    "
  688.                             ev.l=WaitEvent
  689.                             While exit=0
  690.                                 ev.l=WaitEvent
  691.                                 If GadgetHit=1 Then exit=1
  692.                             Wend
  693.                             c2=EventCode
  694.                             exit=0
  695.                             dmax=c2-current
  696.                             cr=(Red(c2)-Red(current))/dmax
  697.                             cg=(Green(c2)-Green(current))/dmax
  698.                             cb=(Blue(c2)-Blue(current))/dmax
  699.                             If c2<>current
  700.                                 For i=0 To dmax Step (Sgn(c2-current))
  701.                                     rr=i*cr+Red(current)
  702.                                     gg=i*cg+Green(current)
  703.                                     bb=i*cb+Blue(current)
  704.                                     RGB current+i,rr,gg,bb
  705.                                 Next
  706.                             End If
  707.                             For i=2 To 12
  708.                                 GTEnable 2,i
  709.                                 Redraw 2,i
  710.                             Next
  711.                             GTSetString 2,13,blank$
  712.  
  713.                         Case 9;               copy
  714.                             For i=2 To 12
  715.                                 GTDisable 2,i
  716.                                 Redraw 2,i
  717.                             Next
  718.                             GTSetString 2,13,"Select colour to copy to      "
  719.                             ev.l=WaitEvent
  720.                             While exit=0
  721.                                 ev.l=WaitEvent
  722.                                 If GadgetHit=1 Then exit=1
  723.                             Wend
  724.                             c2=EventCode
  725.                             exit=0
  726.                             RGB c2,Red(current),Green(current),Blue(current)
  727.                             For i=2 To 12
  728.                                 GTEnable 2,i
  729.                                 Redraw 2,i
  730.                             Next
  731.                             GTSetString 2,13,blank$
  732.  
  733.                         Case 10;              exchange
  734.                             For i=2 To 12
  735.                                 GTDisable 2,i
  736.                                 Redraw 2,i
  737.                             Next
  738.                             GTSetString 2,13,"Select colour to exchange with to"
  739.                             ev.l=WaitEvent
  740.                             While exit=0
  741.                                 ev.l=WaitEvent
  742.                                 If GadgetHit=1 Then exit=1
  743.                             Wend
  744.                             c2=EventCode
  745.                             exit=0
  746.                             rr=Red(current)
  747.                             gg=Green(current)
  748.                             bb=Blue(current)
  749.                             RGB current,Red(c2),Green(c2),Blue(c2)
  750.                             RGB c2,rr,gg,bb
  751.                             For i=2 To 12
  752.                                 GTEnable 2,i
  753.                                 Redraw 2,i
  754.                             Next
  755.                             GTSetString 2,13,blank$
  756.  
  757.                         Case 11;              OK is selected
  758.                             For i=0 To (1 LSL newmode\sm_DisplayDepth - 1)
  759.                                 colours(i)\_Red=Red(i),Green(i),Blue(i)
  760.                             Next
  761.                             exit=1
  762.  
  763.                         Case 12:exit=1;       Cancel is selected
  764.                     End Select
  765.             End Select
  766.         Wend
  767.         DetachGTList 2
  768.         Free GTList 2
  769.         Free Window 2
  770.         Free Screen 1
  771.     Else
  772.         Use Screen 0
  773.         dummy=EasyRequest("Error","Coukld not open screen, check prefs","OK")
  774.     End If
  775.     Use Screen 0
  776.     Use Window 1
  777.     Activate 1
  778.     exit=0
  779.     Return
  780.  
  781. .init:
  782.   Select mode\sm_DisplayDepth
  783.     Case 4;                             16 colour palette select
  784.       shades=12
  785.       For i=0 To 15
  786.         rr=colours(i)\_Red
  787.         gg=colours(i)\_Green
  788.         bb=colours(i)\_Blue
  789.         PalRGB 0,i,rr,gg,bb
  790.       Next
  791.     Case 5;                             32 colour palette select
  792.       shades=12
  793.       For i=0 To 31
  794.         rr=colours(i)\_Red
  795.         gg=colours(i)\_Green
  796.         bb=colours(i)\_Blue
  797.         PalRGB 0,i,rr,gg,bb
  798.       Next
  799.   End Select
  800.   Return
  801.  
  802. Function.w pblue{level}
  803.     ; Select shade of blue
  804.  
  805.     SHARED mode
  806.  
  807.     Select mode\sm_DisplayDepth
  808.         Case 4
  809.             Function Return 1
  810.         Case 5
  811.             Function Return (16+level)
  812.     End Select
  813. End Function
  814.  
  815. Function.w pgreen{level}
  816.  
  817. ; Select shade of green
  818.  
  819.   SHARED mode
  820.  
  821.   Select mode\sm_DisplayDepth
  822.     Case 4
  823.       Function Return (3+level)
  824.     Case 5;                             16 or 32 colour mode
  825.       Function Return (3+level)
  826.   End Select
  827.  
  828. End Function
  829.  
  830. Statement proc3d{o,SX,SY,SZ}
  831.  
  832. ; *** Graphics drawing routine ***
  833.  
  834.   SHARED fxgcol,xscale,yscale,zscale,stuff,centrex,centrey
  835.  
  836.   stuff\x1=stuff\x2
  837.   stuff\x2=stuff\x3
  838.   stuff\y1=stuff\y2
  839.   stuff\y2=stuff\y3
  840.   stuff\x3=centrex-(SX-SY)*xscale
  841.   stuff\y3=centrey+(SX+SY)*yscale-SZ*zscale
  842.  
  843.   Select o
  844.     Case 5
  845.       Line stuff\x2,stuff\y2,stuff\x3,stuff\y3,fxgcol
  846.     Case 85
  847.       Polyf 3,stuff,fxgcol
  848.   End Select
  849. End Statement
  850.  
  851. Statement proc3dd{o,xs,ys}
  852.  
  853. ; *** Finger-tip saving statement ***
  854.  
  855.   SHARED land()
  856.  
  857.   proc3d{o,xs,ys,land(xs,ys)}
  858. End Statement
  859.  
  860. .shift:
  861.  
  862. ; *** S(t)imulates the shifting of the land ***
  863.  
  864.   For longloop.l=1 To faults
  865.     WLocate 5,2
  866.     percent.l=100*longloop/faults
  867.     Print "Faulting "+UStr$(percent)+"% done   "
  868.     If circular Gosub pcircular
  869.     If linear Gosub plinear
  870.     FlushEvents $10
  871.     ev=Event
  872.     If ev=$20
  873.       map=0
  874.       Goto premature
  875.     End If
  876.   Next
  877.  
  878.   map=1
  879.   osize.w=size
  880.   oxscale.q=xscale
  881.   oyscale.q=yscale
  882.   ozscale.q=zscale
  883.   ocircular=circular
  884.   olinear=linear
  885.   ofaults.l=faults
  886.   odelta.q=delta
  887.  
  888.   Return
  889.  
  890. .pcircular:
  891.  
  892. ; *** Circular fault line generator ***
  893.  
  894.   cx=RRnd(0,size-1)
  895.   cy=RRnd(0,size-1)
  896.   cr=(RRnd(0,size-1))^2
  897.   frnd1.l=RRnd(0,2147483646)
  898.   frnd2.l=RRnd(0,2147483646)
  899.   frnd3.l=frnd2-frnd1
  900.   hadd.q=Sgn(frnd3)
  901.   hadd=hadd*Rnd(1)*delta
  902.   For loopx=0 To size
  903.     dx=(loopx-cx)^2
  904.     If dx<cr
  905.       dy=Sqr(cr-dx)
  906.       y1=cy-dy
  907.       y2=cy+dy
  908.       If y1<0 Then y1=0
  909.       If y2>size+1 Then y2=size+1
  910.       For loopy=y1 To y2
  911.         land(loopx,loopy)=land(loopx,loopy)+hadd
  912.       Next
  913.     End If
  914.   Next
  915.   Return
  916.  
  917. .plinear
  918.  
  919. ; *** Linear fault line generator ***
  920.  
  921.   Repeat
  922.     s(0)=RRnd(0,3):s(1)=RRnd(0,3)
  923.   Until s(0)<>s(1)
  924.   Repeat
  925.     For loopj=0 To 1
  926.       Select s(loopj)
  927.         Case 0
  928.           x(loopj)=0
  929.           y(loopj)=RRnd(0,size-1)
  930.         Case 1
  931.           x(loopj)=RRnd(0,size-1)
  932.           y(loopj)=size
  933.         Case 2
  934.           x(loopj)=size
  935.           y(loopj)=RRnd(0,size-1)
  936.         Case 3
  937.           x(loopj)=RRnd(0,size-1)
  938.           y(loopj)=0
  939.       End Select
  940.     Next
  941.   Until x(0)<>x(1) AND y(0)<>y(1)
  942.   m=(y(1)-y(0))/(x(1)-x(0))
  943.   c=y(0)-m*x(0)
  944.   frnd1.l=RRnd(0,2147483646)
  945.   frnd2.l=RRnd(0,2147483646)
  946.   frnd3.l=frnd2-frnd1
  947.   hadd.q=Sgn(frnd3)
  948.   hadd=hadd*Rnd(1)*delta
  949.   For loopx=0 To size
  950.     yy=m*loopx+c
  951.     If yy<0 Then yy=0
  952.     If yy<=size+1
  953.       For loopy=yy To size+1
  954.         land(loopx,loopy)=land(loopx,loopy)+hadd
  955.       Next
  956.     End If
  957.   Next
  958.   Return
  959.  
  960. .levels:
  961.  
  962. ; *** Calculates height levels ***
  963.  
  964.   base=0
  965.   peak=0
  966.   aver=0
  967.   For longloopx.l=0 To size-1
  968.     aver=aver+land(longloopx,size)+land(size,longloopx)
  969.     For longloopy.l=0 To size-1
  970.       WLocate 5,2
  971.       percent=100*(longloopx*size+longloopy+1)/(size*size)
  972.       Print "Calculating levels "+UStr$(percent)+"% done "
  973.       FlushEvents $10
  974.       ev=Event
  975.       If ev=$20
  976.         Goto premature
  977.       End If
  978.       aver=aver+land(longloopx,longloopy)
  979.       av=(land(longloopx,longloopy)+land(longloopx+1,longloopy)+land(longloopx,longloopy+1)+land(longloopx+1,longloopy+1))/4
  980.       If av<base Then base=av
  981.       If av>peak Then peak=av
  982.     Next
  983.   Next
  984.  
  985.   water=aver/(size*size)
  986.  
  987.   range=(peak-water)/shades
  988.   dept=(water-base)/12
  989.   Return
  990.  
  991. Statement patch{X,Y}
  992.  
  993. ; *** Calls necessary patch drawing routines ***
  994.  
  995.   SHARED land(),water,height(),range,dept,fxgcol
  996.   DEFTYPE .b t
  997.  
  998.   height(0)=land(X,Y)-water
  999.   height(1)=land(X+1,Y)-water
  1000.   height(2)=land(X+1,Y+1)-water
  1001.   height(3)=land(X,Y+1)-water
  1002.  
  1003.   pav.q=0
  1004.   For badloop=0 To 3
  1005.     pav=pav+height(badloop)
  1006.   Next
  1007.   pav=pav/4
  1008.  
  1009.   col.w=pav/range
  1010.   sea.w=pav/dept
  1011.   If col<0 Then col=0
  1012.   If sea>0 Then sea=0
  1013.  
  1014. ; *** Draw the sea patch ***
  1015.  
  1016.   fxgcol=pblue{sea+13}
  1017.   proc3d{4,X,Y,water}
  1018.   proc3d{4,X+1,Y,water}
  1019.   proc3d{85,X,Y+1,water}
  1020.   proc3d{85,X+1,Y+1,water}
  1021.   fxgcol=pgreen{col}
  1022.  
  1023. ; *** Calculate what land patch to draw ***
  1024.  
  1025.   total.w=0
  1026.   For loopi=0 To 3
  1027.     If height(loopi)<0
  1028.       total=total+2^loopi
  1029.     Else
  1030.       total=total+2^(loopi+4)
  1031.     End If
  1032.   Next
  1033.  
  1034. ; *** Data for drawing patches ***
  1035.  
  1036.   Select total
  1037.     Case 240
  1038.       proc3dd{4,X,Y}
  1039.       proc3dd{4,X+1,Y}
  1040.       proc3dd{85,X,Y+1}
  1041.       proc3dd{85,X+1,Y+1}
  1042.     Case 120
  1043.       proc3dd{4,X,Y}
  1044.       proc3dd{4,X+1,Y}
  1045.       d=height(0)/(height(0)-height(3))
  1046.       proc3d{85,X,Y+d,water}
  1047.       proc3dd{85,X+1,Y+1}
  1048.       d=height(3)/(height(3)-height(2))
  1049.       proc3d{85,X+d,Y+1,water}
  1050.       fxgcol=2
  1051.       d=height(0)/(height(0)-height(3))
  1052.       proc3d{5,X,Y+d,water}
  1053.     Case 180
  1054.       proc3dd{4,X,Y}
  1055.       proc3dd{4,X,Y+1}
  1056.       proc3dd{85,X+1,Y}
  1057.       d=height(3)/(height(3)-height(2))
  1058.       proc3d{85,X+d,Y+1,water}
  1059.       d=height(1)/(height(1)-height(2))
  1060.       proc3d{85,X+1,Y+d,water}
  1061.       fxgcol=2
  1062.       d=height(3)/(height(3)-height(2))
  1063.       proc3d{5,X+d,Y+1,water}
  1064.     Case 60
  1065.       proc3dd{4,X,Y}
  1066.       proc3dd{4,X+1,Y}
  1067.       d=height(0)/(height(0)-height(3))
  1068.       proc3d{85,X,Y+d,water}
  1069.       d=height(1)/(height(1)-height(2))
  1070.       proc3d{85,X+1,Y+d,water}
  1071.       fxgcol=2
  1072.       d=height(0)/(height(0)-height(3))
  1073.       proc3d{5,X,Y+d,water}
  1074.     Case 210
  1075.       proc3dd{4,X,Y+1}
  1076.       proc3dd{4,X+1,Y+1}
  1077.       proc3dd{85,X,Y}
  1078.       d=height(1)/(height(1)-height(2))
  1079.       proc3d{85,X+1,Y+d,water}
  1080.       d=height(0)/(height(0)-height(1))
  1081.       proc3d{85,X+d,Y,water}
  1082.       fxgcol=2
  1083.       d=height(1)/(height(1)-height(2))
  1084.       proc3d{5,X+1,Y+d,water}
  1085.     Case 90
  1086.       t=0
  1087.       Gosub dangle
  1088.       fxgcol=pgreen{col}
  1089.       t=2
  1090.       Gosub dangle
  1091.     Case 150
  1092.       proc3dd{4,X,Y}
  1093.       proc3dd{4,X,Y+1}
  1094.       d=height(0)/(height(0)-height(1))
  1095.       proc3d{85,X+d,Y,water}
  1096.       d=height(3)/(height(3)-height(2))
  1097.       proc3d{85,X+d,Y+1,water}
  1098.       fxgcol=2
  1099.       d=height(0)/(height(0)-height(1))
  1100.       proc3d{5,X+d,Y,water}
  1101.     Case 30
  1102.       t=0
  1103.       Gosub dangle
  1104.     Case 225
  1105.       d=height(0)/(height(0)-height(3))
  1106.       proc3d{4,X,Y+d,water}
  1107.       d=height(0)/(height(0)-height(1))
  1108.       proc3d{4,X+d,Y,water}
  1109.       proc3dd{85,X,Y+1}
  1110.       proc3dd{85,X+1,Y}
  1111.       proc3dd{85,X+1,Y+1}
  1112.     Case 105
  1113.       proc3dd{4,X+1,Y+1}
  1114.       proc3dd{4,X+1,Y}
  1115.       d=height(3)/(height(3)-height(2))
  1116.       proc3d{85,X+d,Y+1,water}
  1117.       d=height(0)/(height(0)-height(1))
  1118.       proc3d{85,X+d,Y,water}
  1119.       fxgcol=2
  1120.       d=height(3)/(height(3)-height(2))
  1121.       proc3d{85,X+d,Y+1,water}
  1122.     Case 165
  1123.       t=1
  1124.       Gosub dangle
  1125.       fxgcol=pgreen{col}
  1126.       t=3
  1127.       Gosub dangle
  1128.     Case 45
  1129.       t=1
  1130.       Gosub dangle
  1131.     Case 195
  1132.       proc3dd{4,X+1,Y+1}
  1133.       proc3dd{4,X,Y+1}
  1134.       d=height(1)/(height(1)-height(2))
  1135.       proc3d{85,X+1,Y+d,water}
  1136.       d=height(0)/(height(0)-height(3))
  1137.       proc3d{85,X,Y+d,water}
  1138.       fxgcol=2
  1139.       d=height(1)/(height(1)-height(2))
  1140.       proc3d{5,X+1,Y+d,water}
  1141.     Case 75
  1142.       t=2
  1143.       Gosub dangle
  1144.     Case 135
  1145.       t=3
  1146.       Gosub dangle
  1147.   End Select
  1148.   Goto endpatch
  1149.  
  1150. dangle:
  1151.  
  1152. ; *** Draw a different bit ***
  1153.  
  1154.   Select t
  1155.     Case 0
  1156.       proc3dd{4,X,Y}
  1157.       d=height(0)/(height(0)-height(3))
  1158.       proc3d{4,X,Y+d,water}
  1159.       d=height(0)/(height(0)-height(1))
  1160.       proc3d{85,X+d,Y,water}
  1161.       fxgcol=2
  1162.       d=height(0)/(height(0)-height(3))
  1163.       proc3d{5,X,Y+d,water}
  1164.     Case 1
  1165.       proc3dd{4,X+1,Y}
  1166.       d=height(0)/(height(0)-height(1))
  1167.       proc3d{4,X+d,Y,water}
  1168.       d=height(1)/(height(1)-height(2))
  1169.       proc3d{85,X+1,Y+d,water}
  1170.       fxgcol=2
  1171.       d=height(0)/(height(0)-height(1))
  1172.       proc3d{5,X+d,Y,water}
  1173.     Case 2
  1174.       proc3dd{4,X+1,Y+1}
  1175.       d=height(1)/(height(1)-height(2))
  1176.       proc3d{4,X+1,Y+d,water}
  1177.       d=height(3)/(height(3)-height(2))
  1178.       proc3d{85,X+d,Y+1,water}
  1179.       fxgcol=2
  1180.       d=height(1)/(height(1)-height(2))
  1181.       proc3d{5,X+1,Y+d,water}
  1182.     Case 3
  1183.       proc3dd{4,X,Y+1}
  1184.       d=height(3)/(height(3)-height(2))
  1185.       proc3d{4,X+d,Y+1,water}
  1186.       d=height(0)/(height(0)-height(3))
  1187.       proc3d{85,X,Y+d,water}
  1188.       fxgcol=2
  1189.       d=height(3)/(height(3)-height(2))
  1190.       proc3d{5,X+d,Y+1,water}
  1191.   End Select
  1192.   Return
  1193.  
  1194. endpatch:
  1195. End Statement
  1196.  
  1197. .draw:
  1198.  
  1199. ; *** Draw the scene ***
  1200.   centrex=mode\sm_DisplayWidth/2
  1201.   centrey=mode\sm_DisplayHeight*25/100
  1202.  
  1203.   If iff=1 Then Free BitMap 0
  1204.   BitMap 0,mode\sm_DisplayWidth,mode\sm_DisplayHeight,mode\sm_DisplayDepth
  1205.   Use BitMap 0
  1206.  
  1207.   Cls
  1208.   For I=0 To size-1
  1209.     For J=0 To size-1
  1210.       WLocate 5,2
  1211.       percent=100*(I*size+J+1)/(size*size)
  1212.       Print "Drawing, "+UStr$(percent)+"% done            "
  1213.       patch{I,J}
  1214.       FlushEvents $10
  1215.       ev=Event
  1216.       If ev=$20
  1217.         iff=0
  1218.         Goto premature
  1219.       End If
  1220.  
  1221.       If I=size-1
  1222.         ; *** Draw part of the right side of the landscape ***
  1223.         fxgcol=pblue{0}
  1224.         proc3d{4,size,J,base}
  1225.         proc3d{4,size,J+1,base}
  1226.         proc3d{85,size,J,water}
  1227.         proc3d{85,size,J+1,water}
  1228.         fxgcol=0
  1229.         proc3d{5,size,J,water}
  1230.         fxgcol=3
  1231.         proc3d{4,size,J,base}
  1232.         proc3d{4,size,J+1,base}
  1233.         proc3dd{85,size,J}
  1234.         proc3dd{85,size,J+1}
  1235.         fxgcol=0
  1236.         proc3dd{5,size,J}
  1237.       End If
  1238.     Next
  1239.  
  1240. ; *** Draw the left side of the landscape ***
  1241.  
  1242.     fxgcol=pblue{0}
  1243.     proc3d{4,I,size,base}
  1244.     proc3d{4,I+1,size,base}
  1245.     proc3d{85,I,size,water}
  1246.     proc3d{85,I+1,size,water}
  1247.     fxgcol=0
  1248.     proc3d{5,I,size,water}
  1249.     fxgcol=3
  1250.     proc3d{4,I,size,base}
  1251.     proc3d{4,I+1,size,base}
  1252.     proc3dd{85,I,size}
  1253.     proc3dd{85,I+1,size}
  1254.     fxgcol=0
  1255.     proc3dd{5,I,size}
  1256.   Next
  1257.   fxgcol=0
  1258.   proc3d{4,size,size,water}
  1259.   proc3d{5,size,size,base}
  1260.   proc3dd{5,size,size}
  1261.  
  1262.   iff=1
  1263.  
  1264.  
  1265.   If mode\sm_DisplayID<>0
  1266.     Dim SCRtags.TagItem(10)
  1267.  
  1268.     SCRtags(0)\ti_Tag=#SA_DisplayID,mode\sm_DisplayID
  1269.     SCRtags(1)\ti_Tag=#SA_Depth,mode\sm_DisplayDepth
  1270.     SCRtags(2)\ti_Tag=#SA_Width,mode\sm_DisplayWidth
  1271.     SCRtags(3)\ti_Tag=#SA_Height,mode\sm_DisplayHeight
  1272.     SCRtags(4)\ti_Tag=#SA_AutoScroll,-1
  1273.     SCRtags(5)\ti_Tag=#SA_Overscan,#OSCAN_TEXT
  1274.     SCRtags(6)\ti_Tag=#SA_Top,0
  1275.     SCRtags(7)\ti_Tag=#SA_Left,0
  1276.     SCRtags(8)\ti_Tag=#SA_ShowTitle,0
  1277.     SCRtags(9)\ti_Tag=#TAG_END
  1278.  
  1279.     ScreenTags 1,"",&SCRtags(0)
  1280.     *drawscr._Screen = Peek.l(Addr Screen(1))
  1281.     If *drawscr
  1282.         Use Palette 0
  1283.         For i=0 To (1 LSL mode\sm_DisplayDepth - 1)
  1284.             RGB i,colours(i)\_Red,colours(i)\_Green,colours(i)\_Blue
  1285.         Next
  1286.         BltBitMap_ Addr BitMap(0),0,0,*drawscr\_RastPort\_BitMap,0,0,mode\sm_DisplayWidth,mode\sm_DisplayHeight,$C0,-1,0
  1287.         ClickMouse
  1288.         Free Screen 1
  1289.     End If
  1290.   End If
  1291.  
  1292.   Use Screen 0
  1293.   ShowScreen 0
  1294.  
  1295.   Activate 0
  1296.   Use Window 0
  1297.   GTEnable 0,1
  1298.   GTDisable 0,2
  1299.   GTEnable 0,3
  1300.   InnerCls
  1301.   For i=1 To 3
  1302.     Redraw 0,i
  1303.   Next
  1304.  
  1305.   Menus On
  1306.  
  1307.   Return
  1308.  
  1309. .premature
  1310.   Use Screen 0
  1311.   Use Window 0
  1312.   GTEnable 0,1
  1313.   GTDisable 0,2
  1314.   GTEnable 0,3
  1315.   InnerCls
  1316.   For i=1 To 3
  1317.     Redraw 0,i
  1318.   Next
  1319.   Menus On
  1320.   FlushEvents
  1321.   Goto mainloop
  1322.  
  1323. .infotext:
  1324. Data$ ""
  1325. Data$ "   Landscaper by Dave McMinn"
  1326. Data$ "   written in BLITZ BASIC ]["
  1327. Data$ "   on the 21st September `95"
  1328. Data$ ""
  1329. Data$ " (and a bit longer after that)"
  1330. Data$ ""
  1331. Data$ " Feel free to send me some sort"
  1332. Data$ "of monetary denomination (wad)."
  1333. Data$ "A pound note of crispy fiveness"
  1334. Data$ "should suffice, or alternatively"
  1335. Data$ "you could send me your firstborn"
  1336. Data$ "  to be used as a sacrificial"
  1337. Data$ "    offering to the gods..."
  1338.  
  1339. .helptext:
  1340. Data$ "Faults  = number of land shifting operations"
  1341. Data$ "Size    = The size of the landscape (1-160)"
  1342. Data$ ""
  1343. Data$ "To keep the isometric projection looking correct,"
  1344. Data$ "Example screen  Y scale"
  1345. Data$ " 320 x 256      0.5  * X scale"
  1346. Data$ " 640 x 256      0.25 * X scale"
  1347. Data$ " 320 x 512      1    * X scale"
  1348. Data$ " 640 x 512      0.5  * X scale"
  1349. Data$ ""
  1350. Data$ "Z scale is used to exagerate the height"
  1351. Data$ "Delta is the most any part of land can change by"
  1352. Data$ "in one shift operation."
  1353.  
  1354. .colourvalues:
  1355. Data.w 0,0,0,1,2,9,15,14,1,0,3,0
  1356. Data.w 0,4,0,0,5,0,0,6,0,0,7,0
  1357. Data.w 0,8,0,0,9,0,2,10,2,4,11,4
  1358. Data.w 6,12,6,9,13,9,13,14,13,15,15,15
  1359. Data.w 0,0,4,0,0,5,0,1,6,0,1,7
  1360. Data.w 1,2,8,1,2,9,1,3,9,2,4,10
  1361. Data.w 2,4,11,2,5,12,3,6,13,3,7,14
  1362. Data.w 4,8,15,5,9,15,15,0,0,15,0,15
  1363.  
  1364. _screenpens:
  1365. Data.w -1
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371. ;ASL Screenmode Requester and ScreenTags
  1372. ;Curt Esser  camge@ix.netcom.com
  1373. ;use all or parts in any way you like
  1374. ;last modified Aug 8, 1998
  1375.  
  1376. ;NEEDS amigalibs.res, WB 2.01+
  1377.  
  1378. WBStartup
  1379.  
  1380. WBenchToFront_
  1381.  
  1382. NoCli
  1383.  
  1384. WbToScreen 1                               ;we use WB for mode requester
  1385.  
  1386. LoadFont 0,"topaz.font",8                  ;load test screen's font
  1387. *fn=Addr IntuiFont (0)                     ;pointer to screen font
  1388.  
  1389. sm$="Select A Screen Mode:"                ;title for mode requester
  1390.  
  1391. If NTSC=True                               ;set default screen mode
  1392.   imode.l=$19004                           ;NTSC hi-res lace for NTSC
  1393.   iheight.w=400
  1394. Else
  1395.   imode.l=$29004                           ;PAL hi-res laced for PAL
  1396.   iheight.w=512
  1397. EndIf
  1398.  
  1399. Dim SMRtags.TagItem(19)                    ;taglist for mode requester
  1400.  
  1401. SMRtags(0)\ti_Tag=#ASLSM_InitialLeftEdge,160     ;these are the position for the
  1402. SMRtags(1)\ti_Tag=#ASLSM_InitialTopEdge,10       ;screenmode requester
  1403. SMRtags(2)\ti_Tag=#ASLSM_InitialWidth,320
  1404. SMRtags(3)\ti_Tag=#ASLSM_InitialHeight,200
  1405. SMRtags(4)\ti_Tag=#ASLSM_InitialDisplayID,imode  ;these are shown as "selected"
  1406. SMRtags(5)\ti_Tag=#ASLSM_InitialDisplayDepth,3   ;when the requester opens
  1407. SMRtags(6)\ti_Tag=#ASLSM_InitialDisplayWidth,640
  1408. SMRtags(7)\ti_Tag=#ASLSM_InitialDisplayHeight,iheight
  1409. SMRtags(8)\ti_Tag=#ASLSM_InitialOverscanType,1
  1410. SMRtags(9)\ti_Tag=#ASLSM_InitialInfoOpened,0     ;no "properties" window
  1411. SMRtags(10)\ti_Tag=#ASLSM_DoDepth,1              ;0 for no depth selector
  1412. SMRtags(11)\ti_Tag=#ASLSM_DoOverscanType,1       ;0 for no OverScan selector
  1413. SMRtags(12)\ti_Tag=#ASLSM_DoWidth,1              ;0 for no width gadget
  1414. SMRtags(13)\ti_Tag=#ASLSM_DoHeight,1             ;0 for no height gadget
  1415. SMRtags(14)\ti_Tag=#ASLSM_MinHeight,200          ;minimum height allowed
  1416. SMRtags(15)\ti_Tag=#ASLSM_MinWidth,320           ;minimum width allowed
  1417. SMRtags(16)\ti_Tag=#ASLSM_MinDepth,3             ;minimum depth allowed
  1418. SMRtags(17)\ti_Tag=#ASLSM_TitleText,&sm$         ;pointer to requester title$
  1419. SMRtags(18)\ti_Tag=#TAG_DONE
  1420.  
  1421. ;
  1422. ; ScreenMode requester returns the ScreenMode structure
  1423. ;
  1424.  
  1425. *sreq.ScreenModeRequester=0
  1426. *sreq=AllocAslRequest_(2,&SMRtags(0)\ti_Tag)
  1427. ok.b=AslRequest_(*sreq,&SMRtags(0)\ti_Tag)
  1428.  
  1429. If ok<>0       ;if 0, the cancel gadget was hit
  1430.  
  1431.   ;------- read the results into variables
  1432.   ;this part is not really necessary, but makes it possible to
  1433.   ;just make up the screen without using the requester every time
  1434.   ;the program is started
  1435.   ;these results could be saved into a "prefs" file
  1436.   ;and reloaded into your program before opening the screen
  1437.  
  1438.   Display.l=*sreq\sm_DisplayID
  1439.   Oscan.w=*sreq\sm_OverscanType
  1440.   Dpth.w=*sreq\sm_DisplayDepth
  1441.   Widh.l=*sreq\sm_DisplayWidth
  1442.   Heit.l=*sreq\sm_DisplayHeight
  1443.  
  1444.   ;------- now make the "Program's" screen --------------------
  1445.   ; we will make it up in back and pop to the front when ready
  1446.  
  1447.  
  1448.   Dim SCRtags.TagItem(12)
  1449.  
  1450.   SCRtags(0)\ti_Tag=#SA_DisplayID,Display
  1451.   SCRtags(1)\ti_Tag=#SA_Overscan,Oscan
  1452.   SCRtags(2)\ti_Tag=#SA_Depth,Dpth
  1453.   SCRtags(3)\ti_Tag=#SA_Width,Widh
  1454.   SCRtags(4)\ti_Tag=#SA_Height,Heit
  1455.   SCRtags(5)\ti_Tag=#SA_Top,0
  1456.   SCRtags(6)\ti_Tag=#SA_Left,0
  1457.   SCRtags(7)\ti_Tag=#SA_AutoScroll,1         ;autoscroll is on!
  1458.   SCRtags(8)\ti_Tag=#SA_Pens,?DriPens        ;List of 13 Dripens
  1459. ;  SCRtags(9)\ti_Tag=#SA_Behind,1             ;make screen in back of display
  1460.   SCRtags(9)\ti_Tag=#SA_ShowTitle,0
  1461.   SCRtags(10)\ti_Tag=#TAG_DONE
  1462.  
  1463.   d.l=ScreenTags(0,"Test Screen",&SCRtags(0))    ;open the test screen
  1464.  
  1465.   Window 1,10,10,300,100,$1000|$8,"Screen info",1,0  ;and a small window
  1466.   NPrint d
  1467.   NPrint Peek.l(Addr Screen(0))
  1468.   NPrint "$"+Hex$(Display)
  1469.   NPrint "Depth=",Dpth
  1470.   NPrint "Press close gadget to end"
  1471.  
  1472.   ShowScreen 0                               ;now bring screen to the front
  1473.  
  1474.  
  1475.   Repeat                                     ;just wait until the window
  1476.     ev.l=WaitEvent                           ;close gadget is pressed
  1477.   Until ev=$200
  1478.  
  1479.  
  1480. Else
  1481.   Request "","Cancelled!","OK"
  1482.   End
  1483. EndIf
  1484. If (*sreq) Then FreeAslRequest_(*sreq)       ;we MUST free this ourselves
  1485.  
  1486.  
  1487. End
  1488.  
  1489. Even
  1490. DriPens
  1491. Dc.w  -1
  1492.  
  1493.  
  1494.  
  1495.  
  1496.